<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        a,li{
            width: 30px;
            height: 30px;
            border: 2px solid red;
            display: block;
            text-align: center;
            line-height: 30px;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <ul>
        <!-- <a href="">1</a>
        <a href="">2</a>
        <a href="">3</a> -->
        <li>1</li>
        <li>2</li>
        <li>3</li>
    </ul>
</body>
</html>
<script>
    const lis = document.querySelectorAll('li')
    for (let index = 0; index < lis.length; index++) {
        const element = lis[index];

        // console.log(element.innerText);
        element.onclick = function(){
            // console.log(element.innerText);
            console.log(this.innerText);
        }
        
    }
</script>